//(function($) {})(jQuery);


var pageIndex = 0;

var headItems = null;

function gotoTargetPage(){
	if(pageIndex == 0){
		$('#menuPagePanel:visible').hide();
		$('div[id^="menuPage_"]').hide();
		
		$('#friendsChatPanel:visible').hide();
		$('#chatroomPanel:visible').hide();
		$('#contactsPanel:hidden').show();
		if(headItems == null)
			headItems = $('div[class^="framehead_item_"] ') ;

		headItems.find('.head_hdec').hide();
		headItems.eq(pageIndex).find('.head_hdec').show();
		
	}else if(pageIndex == 1){
		$('#menuPagePanel:visible').hide();
		$('div[id^="menuPage_"]').hide();
		
		$('#contactsPanel:visible').hide();
		$('#chatroomPanel:visible').hide();
		$('#friendsChatPanel:hidden').show();
		if(headItems == null)
			headItems = $('div[class^="framehead_item_"] ') ;

		headItems.find('.head_hdec').hide();
		headItems.eq(pageIndex).find('.head_hdec').show();
	}else if(pageIndex == 2){
		$('#menuPagePanel:visible').hide();
		$('div[id^="menuPage_"]').hide();
		
		$('#friendsChatPanel:visible').hide();
		$('#contactsPanel:visible').hide();
		$('#chatroomPanel:hidden').show();
		if(headItems == null)
			headItems = $('div[class^="framehead_item_"] ') ;

		headItems.find('.head_hdec').hide();
		headItems.eq(pageIndex).find('.head_hdec').show();
	}
}


function mobileTouchEvent(){
	$('body').live('swipeleft',function(){ 
		if(pageIndex <2){
			pageIndex = pageIndex + 1;
			gotoTargetPage();
		}
	}); 
	$('body').live('swiperight',function(){ 
		if(pageIndex >0){
			pageIndex = pageIndex - 1;
			gotoTargetPage();
		}
	}); 
	
	$('.framehead_item_chatroom').click(function(){
		pageIndex = 1;
		gotoTargetPage();

	});

	$('.framehead_item_contacts').click(function(){
		pageIndex = 0;
		gotoTargetPage();
	
	});
	
	$('.framehead_item_news').click(function(){
		pageIndex = 2;
		gotoTargetPage();
	
	});
	
	
}



function initContentSize(){
	Contentheight = $('body').height() - $('.framehead').height() - $('#footer').height() - 90;
	$('#mainPanel').css('height',Contentheight + 15);
	$('#friendsChatPanel').css('height',Contentheight);
	$('#contactsPanel').css('height',Contentheight);
	$('#chatroomPanel').css('height',Contentheight);
	$('.contact_messages_container').css('height',Contentheight-5);
	$('.contact_message_container').css('height',Contentheight-55);

	if(screenWidth>400){
		screenWidth = $('body').width();
		var prentW = (screenWidth - 400)*50/screenWidth +'%';
	
		$('.ui-page').css({
				'width' :'400px',
				'left':prentW,
				'border-left' : '1px solid black',
				'border-right':'1px solid black',
			});
	} 
	//alert($('.framehead').height());
	//alert($('#footer').height());
	//alert(Contentheight);

}

